package com.hksj.Intelligentmanagement.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hksj.Intelligentmanagement.common.Rest;
import com.hksj.Intelligentmanagement.dto.HqEnvironmentHistoryDataDTO;
import com.hksj.Intelligentmanagement.dto.RoomEnvSyncQuery;
import com.hksj.Intelligentmanagement.service.HqEnvironmentHistoryDataService;
import com.hksj.Intelligentmanagement.vo.HqEnvironmentHistoryDataVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "华嵌数据查询")
@RequestMapping("/api/hqEnvironmentHistoryData")
public class HqEnvironmentHistoryDataController {

    @Autowired
    private HqEnvironmentHistoryDataService handNumbnessStatisticalService;

    @ApiOperation(value = "华嵌历史数据查询")
    @PostMapping("/selectHqEnvironmentHistoryData")
    public Rest<IPage<HqEnvironmentHistoryDataVo>> selectHandNumbnessCount(@RequestBody HqEnvironmentHistoryDataDTO dto) {
        return Rest.ok(handNumbnessStatisticalService.selectHqEnvironmentHistoryData(dto));
    }

    @ApiOperation(value = "华嵌测试查询")
    @PostMapping("/queryTestForHQ")
    public Rest queryTestForHQ() {
        List<Map<String, Object>> result = handNumbnessStatisticalService.queryTestForHQ();
        return Rest.ok(result);
    }

    @ApiOperation(value = "手动同步")
    @PostMapping("/syncData")
    public Rest syncData(@RequestBody RoomEnvSyncQuery query){
        query.setPageSize(200);
        handNumbnessStatisticalService.toSyncData(query);
        return Rest.ok();
    }

    @ApiOperation(value = "开启自动同步")
    @GetMapping("/enableAutoSync/{status}")
    public Rest enableAutoSync(@PathVariable Integer status){
        handNumbnessStatisticalService.enableAutoSync(status);
        return Rest.ok();
    }
}
